package com.itheima.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.admin.mapper.RoleModuleMapper;
import com.itheima.admin.pojo.RoleModule;
import com.itheima.admin.service.IRoleModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class RoleModuleServiceImpl implements IRoleModuleService {

    @Autowired
    private RoleModuleMapper roleModuleMapper;
    @Override
    public List<Integer> selectRoleModules(String id) {
        QueryWrapper<RoleModule> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("role_id",id);
        List<RoleModule> list = roleModuleMapper.selectList(objectQueryWrapper);
        List<Integer> result = new ArrayList<>();
        for (RoleModule roleModule : list) {
            result.add(Integer.parseInt(roleModule.getModuleId()));
        }
        return result;
    }
}
